←Select platform

CopyData(Byte[],Int32) Method

Summary

Updates the data of this RasterImage.

Syntax

C#
VB
Java
WinRT C#
C++
public void CopyData(  
   byte[] data, 
   int dataOffset 
) 
Public Overloads Sub CopyData( _ 
   ByVal data() As Byte, _ 
   ByVal dataOffset As Integer _ 
)  
public void CopyData(  
   byte[] data, 
   int dataOffset 
) 
public void copyData( 
  byte[] data,  
  int dataOffset,  
  long size 
) 
             
 function Leadtools.RasterImage.CopyData(Byte[],Int32)(  
   data , 
   dataOffset  
) 
public: 
void CopyData(  
   array<byte>^ data, 
   int dataOffset 
)  

Parameters

data
Buffer containing the image new data.

dataOffset
Offset into data where the copy operation should begin.

Remarks

The byte array that you specify will be copied.

The data is copied as is into the internal memory of this RasterImage.

Example

C#
VB
Silverlight C#
Silverlight VB
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing; 
using Leadtools.ImageProcessing.Core; 
using Leadtools.ImageProcessing.Color; 
using Leadtools.Dicom; 
using Leadtools.Drawing; 
using Leadtools.Controls; 
using LeadtoolsExamples.Common; 
using Leadtools.Svg; 
 
public void CopyDataExample() 
{ 
   RasterCodecs codecs = new RasterCodecs(); 
   RasterImage image = codecs.Load(Path.Combine(ImagesPath.Path, "IMAGE1.CMP")); 
 
   byte[] data = new byte[image.BytesPerLine * image.Height]; 
   int val = 0; 
   for (int x = 0; x < data.Length; x++) 
   { 
      data[x] = (byte)val; 
      val++; 
      if (val > 255) 
         val = 0; 
   } 
   image.CopyData(data, 0); 
 
   codecs.Save(image, Path.Combine(ImagesPath.Path, "CopyData.bmp"), RasterImageFormat.Bmp, 0); 
 
   image.Dispose(); 
   codecs.Dispose(); 
} 
Imports Leadtools 
Imports Leadtools.Codecs 
Imports Leadtools.ImageProcessing 
Imports Leadtools.ImageProcessing.Core 
Imports Leadtools.ImageProcessing.Color 
Imports Leadtools.Controls 
Imports Leadtools.Dicom 
Imports Leadtools.Drawing 
Imports Leadtools.Svg 
 
Public Sub CopyDataExample() 
   Dim codecs As RasterCodecs = New RasterCodecs() 
   Dim image As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "IMAGE1.CMP")) 
 
   Dim data As Byte() = New Byte(image.BytesPerLine * image.Height - 1) {} 
   Dim val As Integer = 0 
   Dim x As Integer = 0 
   Do While x < data.Length 
      data(x) = CByte(val) 
      val += 1 
      If val > 255 Then 
         val = 0 
      End If 
      x += 1 
   Loop 
   image.CopyData(data, 0) 
 
   codecs.Save(image, Path.Combine(LEAD_VARS.ImagesDir, "CopyData.bmp"), RasterImageFormat.Bmp, 0) 
 
   image.Dispose() 
   codecs.Dispose() 
End Sub 
 
Public NotInheritable Class LEAD_VARS 
   Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images" 
End Class 
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Dicom; 
using Leadtools.ImageProcessing; 
using Leadtools.ImageProcessing.Core; 
using Leadtools.ImageProcessing.Color; 
using Leadtools.Examples; 
using Leadtools.Windows.Media; 
 
public void CopyDataExample(RasterImage image, Stream destStream) 
{ 
   byte[] data = new byte[image.BytesPerLine * image.Height]; 
   int val = 0; 
   for (int x = 0; x < data.Length; x++) 
   { 
      data[x] = (byte)val; 
      val++; 
      if (val > 255) 
         val = 0; 
   } 
   image.CopyData(data, 0); 
 
   RasterCodecs codecs = new RasterCodecs(); 
   codecs.Save(image, destStream, RasterImageFormat.Png, 0); 
 
   image.Dispose(); 
} 
Imports Leadtools 
Imports Leadtools.Codecs 
Imports Leadtools.Dicom 
Imports Leadtools.ImageProcessing 
Imports Leadtools.ImageProcessing.Core 
Imports Leadtools.ImageProcessing.Color 
Imports Leadtools.Windows.Media 
 
Public Sub CopyDataExample(ByVal image As RasterImage, ByVal destStream As Stream) 
   Dim data As Byte() = New Byte(image.BytesPerLine * image.Height - 1) {} 
   Dim val As Integer = 0 
   Dim x As Integer = 0 
   Do While x < data.Length 
      data(x) = CByte(val) 
      val += 1 
      If val > 255 Then 
         val = 0 
      End If 
      x += 1 
   Loop 
   image.CopyData(data, 0) 
 
   Dim codecs As RasterCodecs = New RasterCodecs() 
   codecs.Save(image, destStream, RasterImageFormat.Png, 0) 
 
   image.Dispose() 
End Sub 

Requirements

Target Platforms

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.

Leadtools Assembly